<div class="panel panel-default" style="height: 430px;">
    <div class="panel-heading case-detail-title">
        <ul class="nav nav-line-tab">
            <li class="active">跟进</li>
        </ul>
    </div>
    <div class="tab-content">
        <div class="tab-pane fade in active" id="debt-tel">
            <form id="edit_activity_form" name="edit_activity_form" method="post" action="/custom/index/saveActivity">
                <input type="hidden" name="custom_id" value="{$custom.id}"/>
                <input type="hidden" name="type" value="1"/>
                <div class="panel-body">
                    <div class="row row-inside">
                        <div class="col-xs-12">
                            <div class="form-group">
                                <label>电话<span class="text-important">*</span></label> <label for="phone" class="error"></label>
                                <div class="dropdown dropdown-block">
                                    <input class="form-control" type="text" name="phone" id="phone" value="" readonly>
                                </div>
                            </div>
                        </div>
                        <div class="col-xs-6">
                            <div class="form-group">
                                <label>职位<span class="text-important">*</span></label> <label for="job" class="error"></label>
                                <div class="dropdown dropdown-block">
                                    <input class="form-control" type="text" name="job" id="job" value="">
                                </div>
                            </div>
                            <div class="form-group">
                                <label>优先级<span class="text-important">*</span></label> <label for="priority" class="error"></label>
                                <div class="dropdown dropdown-block">
                                    <a class="btn btn-default" data-toggle="dropdown">
                                        <span name="priority_name" class="option-name">低</span> <span class="caret"></span>
                                    </a>
                                    <ul class="dropdown-menu dropdown-option-menu">
                                        <li><a data-value="0" role="button">低</a></li>
                                        <li><a data-value="1" role="button">中</a></li>
                                        <li><a data-value="2" role="button">高</a></li>
                                    </ul>
                                    <input name="priority" id="priority" class="option-value" type="hidden" value="0">
                                </div>
                            </div>
                        </div>
                        <div class="col-xs-6">
                            <div class="form-group">
                                <label>联系人<span class="text-important">*</span></label>  <label for="objective" class="error"></label>
                                <div class="dropdown dropdown-block">
                                    <input class="form-control" type="text" name="objective" id="objective" value="">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="next_follow_time">下次跟进</label>
                                <input class="form-control" data-toggle="singledateleftmindate" type="text" id="next_follow_time" name="next_follow_time">
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="info">记录<span class="text-important">*</span></label> <label for="info" class="error"></label>
                        <textarea class="form-control" id="info" name="info" rows="3"></textarea>
                    </div>
                    <div class="form-group text-right">
                        <if condition="fa_has_auth($custom['leader_user_id'])">
                            <button class="btn btn-default" type="button" id="clearActivity">清除</button>
                            <button class="btn btn-primary" type="submit" id="saveActivity">保存</button>
                            <else/>
                            <button class="btn btn-default" disabled type="button" id="clearActivity">清除</button>
                            <button class="btn btn-primary" disabled type="submit" id="saveActivity">保存</button>
                        </if>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        $("#edit_activity_form").validate({
            submitHandler: function () {
                $.post($("#edit_activity_form").attr("action"), $("#edit_activity_form").serialize(), function (data) {
                    if (data === "0") {
                        alertify.alert("保存成功!", function () {
                            location.reload();
                        });
                    } else {
                        alertify.alert(data);
                    }
                }).error(function (msg, url, line) {
                    alert(msg.responseText);
                });
            },
            ignore: "",
            rules: {
                name: {
                    required: true
                },
                job: {
                    required: true
                },
                phone: {
                    required: true,
                    isPhone: true
                },
                info: {
                    required: true
                }
            },
            messages: {
                name: {
                    required: "请填写"
                },
                job: {
                    required: "请填写"
                },
                phone: {
                    required: "请填写"
                },
                info: {
                    required: "请填写"
                }
            }
        });

        $("#clearActivity").click(reset_edit_activity_form);
        $('a[data-type="edit-follow"]').click(function () {
            reset_edit_activity_form();
            var $this = $(this);
            var node = $this.parent().parent().parent();
            edit_edit_activity_form(node,$this.text());
        });
    });

    function reset_edit_activity_form() {
//        $('#edit_activity_form input[name="id"]').val('');
        $('#edit_activity_form input[name="phone"]').val('');
        $('#edit_activity_form input[name="job"]').val('');
        $('#edit_activity_form input[name="objective"]').val('');

        $('#edit_activity_form input[name="activity_time"]').val('');
        $('#edit_activity_form textarea[name="info"]').val('');
    }

    function edit_edit_activity_form(node,number) {
//        $('#edit_activity_form input[name="phone"]').val(node.data('phone'));
        $('#edit_activity_form input[name="phone"]').val(number);
        $('#edit_activity_form input[name="job"]').val(node.data('job'));
        $('#edit_activity_form input[name="objective"]').val(node.data('name'));

    }

</script>